/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package test_1;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class Main {
    public static String docBase = "D:\\my\\";
    public static int port = 8001;
    public static String encode = "utf-8";
    
    public void start() throws IOException{
        ServerSocket server = new ServerSocket(port);
        Socket s = null;
        System.out.println("服务器已经启动");
        System.out.println("端口："+port);
        System.out.println("根目录："+docBase);
        while(true){
             //.out.println("server开始");
            s = server.accept();
            if(s != null)
                try {
                     //System.out.println("server accept");
                new ServiceThread(s).start();
               
            } catch (Exception ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            }
             //.out.println("server accept");
        }
    }
    

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            // TODO code application logic here
            new Main().start();
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}
